﻿using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using Supermodel.DomainModel;
using Supermodel.MVC.FormModels;
using Supermodel.MVC.FormModels.Metadata;

namespace Domain
{
    public class UserFormModel : FormModelForEntityBase<User>
    {
        [DisplayName("First Name"), Required]
        public string FirstName { get; set; }
        
        [Required]
        public string LastName { get; set; }
        public FormModelEnumRadioSelect<User.SexEnum> Sex { get; set; }

        public DropdownFormModel Role { get; set; }
        
        [ScreenOrder(50), DisplayOnly]
        public bool Active { get; set; }

        public BinaryFileFormModel Resume { get; set; }

        public override FormModelForEntityBase<User> InitFromDomainModelEntity(User domainModel)
        {
            base.InitFromDomainModelEntity(domainModel);
            Sex.Layout = RadioSelectFormModel.RadioLayout.Horizontal;
            return this;
        }
    }
    
    public class User : Entity<User>
    {
        public enum SexEnum { [Description("A guy")]Man, [ScreenOrder(50)]Woman };
        
        public User()
        {
            Active = true;
            Sex = SexEnum.Man;
        }
        
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public bool Active { get; set; }
        public EFCFEnum Sex { get; set; }
        
        public virtual UserRole Role { get; set; }

        public BinaryFile Resume { get; set; }

        public void Disable()
        {
            Active = false;
        }
        
        public override string Label
        {
            get { return FirstName + " " + LastName; }
        }
    }
}
